﻿using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using Dapper;
using DB.SchemaSync.Library.Models;

namespace DB.SchemaSync.SqlServer
{
	public partial class SqlServerDbProvider
	{
		private async Task<IEnumerable<Schema>> GetSchemaAsync(IDbConnection connection)
		{
			var schemas = await connection.QueryAsync<string>(
				@"SELECT [name] FROM sys.schemas
				WHERE [name] NOT IN ('guest', 'sys', 'information_schema') AND [name] NOT LIKE 'db[_]%'");

			return schemas.Select(s => new Schema() { Name = s });
		}
	}
}